﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mindfor.Web.Models
{
	/// <summary>
	/// Defines properties for pager data.
	/// </summary>
	public class PagerModel
	{
		/// <summary>
		/// Gets or sets total items count.
		/// </summary>
		public int ItemsCount { get; set; }

		/// <summary>
		/// Gets or sets items per page.
		/// </summary>
		public int ItemsPerPage { get; set; }

		/// <summary>
		/// Gets or sets current page index. If <c>Null</c> then current page is taken from current route.
		/// </summary>
		public int? CurrentPage { get; set; }

		/// <summary>
		/// Gets or sets first page index in route path. Default is 1.
		/// Visible page numbers will start from 1 whatever.
		/// </summary>
		public int FirstPageIndex { get; set; }

		/// <summary>
		/// Gets or sets route page key name. Default is "page".
		/// </summary>
		public string PageKey { get; set; }

		/// <summary>
		/// Gets or sets route action name. If <c>Null</c> then current action is used.
		/// </summary>
		public string ActionName { get; set; }

		/// <summary>
		/// Gets or sets route controller name. If <c>Null</c> then current controller is used.
		/// </summary>
		public string ControllerName { get; set; }

		/// <summary>
		/// Initializes new instance with first page index = 1.
		/// Current page is taken from route values.
		/// </summary>
		/// <param name="itemsCount">Total items count.</param>
		/// <param name="itemsPerPage">Items per page.</param>
		public PagerModel(int itemsCount, int itemsPerPage)
		{
			ItemsCount = itemsCount;
			ItemsPerPage = itemsPerPage;
			PageKey = "page";
			FirstPageIndex = 1;
		}

		/// <summary>
		/// Initializes new instance with custom first page index.
		/// Current page is taken from route values.
		/// </summary>
		/// <param name="itemsCount">Total items count.</param>
		/// <param name="itemsPerPage">Items per page.</param>
		/// <param name="firstPageIndex">Index of first page.</param>
		public PagerModel(int itemsCount, int itemsPerPage, int firstPageIndex)
			: this(itemsCount, itemsPerPage)
		{
			FirstPageIndex = firstPageIndex;
		}
	}
}
